package com.example.demo2.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Robin
 * @Description: 异步线程测试controller
 */
@RestController
@RequestMapping("/demo")
public class Controller {

    @Autowired
    TestAsync testAsync;

    @RequestMapping(value = "/test",method = RequestMethod.GET)
    public String testHello (){
        testAsync.test2();
        testAsync.test3();
        System.out.println("hello world 1");
        /*
        不用线程池，创建单个线程
        new Thread(()->{
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("hello world 0 ");
        }).start();

        */
        return "haha";
    }


}
